package info.tsukaworld.actor;

import info.tsukaworld.gui.GameKeyListener;
import java.awt.event.*;

public class Player extends AnimatedActor
{
    private GameKeyListener listener;
    
    public Player()
    {
        super();
        setMoveSpeed(13);
    }
    
    public void act()
    {
        listener.checkInput();
        super.act();
    }
    
    public void setInput( GameKeyListener k )
    { listener = k; }
    
    public boolean canMove()
    {
        Actor a = this.getGrid().get(this.getLocation().getAdjacentLocation(this.getDirection()));

        if( a != null)
        {
            if(a instanceof Ladder)
            {
                ((Ladder)a).toggle();
            }
        }
        return super.canMove();
    }
    
    public String[][] setAnimations()
    {
        String[][] temp = new String[4][13];
        //Up animations
        temp[0][0] = "PlayerUp4.gif";
        temp[0][1] = "PlayerUp5.gif";
        temp[0][2] = "PlayerUp6.gif";
        temp[0][3] = "PlayerUp7.gif";
        temp[0][4] = "PlayerUp6.gif";
        temp[0][5] = "PlayerUp5.gif";
        temp[0][6] = "PlayerUp4.gif";
        temp[0][7] = "PlayerUp3.gif";
        temp[0][8] = "PlayerUp2.gif";
        temp[0][9] = "PlayerUp1.gif";
        temp[0][10] = "PlayerUp2.gif";
        temp[0][11] = "PlayerUp3.gif";
        temp[0][12] = "PlayerUp4.gif";
        //Right animations
        temp[1][0] = "PlayerRight4.gif";
        temp[1][1] = "PlayerRight5.gif";
        temp[1][2] = "PlayerRight6.gif";
        temp[1][3] = "PlayerRight7.gif";
        temp[1][4] = "PlayerRight6.gif";
        temp[1][5] = "PlayerRight5.gif";
        temp[1][6] = "PlayerRight4.gif";
        temp[1][7] = "PlayerRight3.gif";
        temp[1][8] = "PlayerRight2.gif";
        temp[1][9] = "PlayerRight1.gif";
        temp[1][10] = "PlayerRight2.gif";
        temp[1][11] = "PlayerRight3.gif";
        temp[1][12] = "PlayerRight4.gif";
        //Down animations
        temp[2][0] = "PlayerDown4.gif";
        temp[2][1] = "PlayerDown5.gif";
        temp[2][2] = "PlayerDown6.gif";
        temp[2][3] = "PlayerDown7.gif";
        temp[2][4] = "PlayerDown6.gif";
        temp[2][5] = "PlayerDown5.gif";
        temp[2][6] = "PlayerDown4.gif";
        temp[2][7] = "PlayerDown3.gif";
        temp[2][8] = "PlayerDown2.gif";
        temp[2][9] = "PlayerDown1.gif";
        temp[2][10] = "PlayerDown2.gif";
        temp[2][11] = "PlayerDown3.gif";
        temp[2][12] = "PlayerDown4.gif";
        //Left animations
        temp[3][0] = "PlayerLeft4.gif";
        temp[3][1] = "PlayerLeft5.gif";
        temp[3][2] = "PlayerLeft6.gif";
        temp[3][3] = "PlayerLeft7.gif";
        temp[3][4] = "PlayerLeft6.gif";
        temp[3][5] = "PlayerLeft5.gif";
        temp[3][6] = "PlayerLeft4.gif";
        temp[3][7] = "PlayerLeft3.gif";
        temp[3][8] = "PlayerLeft2.gif";
        temp[3][9] = "PlayerLeft1.gif";
        temp[3][10] = "PlayerLeft2.gif";
        temp[3][11] = "PlayerLeft3.gif";
        temp[3][12] = "PlayerLeft4.gif";
        return temp;
    }
}